open(BUFF,"./ILL_SEP/ILL_GNT_SAMPLES") or die "no file found\n";
while(<BUFF>)
{
	chomp($_);
	@a = split(/ |-/,$_);
	$hash{"$a[0]-$a[1]-$a[2]"} = "ill";
}
open(BUFF,"./AFFY_SEP/AFFY_GNT_SAMPLES") or die "no file found affy\n";
while(<BUFF>)
{
        chomp($_);
        @a = split(/ |-/,$_);
        $hash{"$a[0]-$a[1]-$a[2]"} = "affy";
}
open(BUFF,"GE.txt")  or die "no file found GE.txt\n";
$line = <BUFF>;
chomp($line);
@array = split(/\t/,$line);
@order = ("gene");
open(WRBUFF1,">./ILL_SEP/GE.txt") or die "not able to write ill\n";
open(WRBUFF2,">./AFFY_SEP/GE.txt") or die "not able to write affy\n";
print WRBUFF1 "$array[0]";
print WRBUFF2 "$array[0]";
for($i=1;$i<@array;$i++)
{
	if($hash{$array[$i]} eq "ill")
	{
		push(@order,"ill");	
		print WRBUFF1 "\t$array[$i]";
	}
	elsif($hash{$array[$i]} eq "affy")
	{
		push(@order,"affy");
		print WRBUFF2 "\t$array[$i]";
	}
	else
	{
		print "$array[$i]\n";
	}
}
print WRBUFF1 "\n";
print WRBUFF2 "\n";
while($line = <BUFF>)
{
	chomp($line);
	@array = split(/\t/,$line);
	print WRBUFF1 "$array[0]";
	print WRBUFF2 "$array[0]";
	for($i=1;$i<@array;$i++)
	{
		if($order[$i] eq "ill")
		{
			print WRBUFF1 "\t$array[$i]";
		}
		elsif($order[$i] eq "affy")
		{
			print WRBUFF2 "\t$array[$i]";
		}
		else
		{
			die "no column found $i\n";
		}
	}
	print WRBUFF1 "\n";
	print WRBUFF2 "\n";
}
open(WRBUFF1,">./ILL_SEP/SNP.txt") or die "not able to write ill\n";
open(WRBUFF2,">./AFFY_SEP/SNP.txt") or die "not able to write affy\n";
open(BUFF,"SNP.txt")  or die "no file found SNP.txt\n";
while($line = <BUFF>)
{
        chomp($line);
        @array = split(/\t/,$line);
        print WRBUFF1 "$array[0]";
        print WRBUFF2 "$array[0]";
        for($i=1;$i<@array;$i++)
        {
                if($order[$i] eq "ill")
                {
                        print WRBUFF1 "\t$array[$i]";
                }
                elsif($order[$i] eq "affy")
                {
                        print WRBUFF2 "\t$array[$i]";
                }
                else
                {
                        die "no column found $i\n";
                }
        }
        print WRBUFF1 "\n";
        print WRBUFF2 "\n";
}

#print "@order\n";
